package com.shao.function;

import com.sun.org.apache.bcel.internal.generic.SWITCH;

import java.lang.invoke.SwitchPoint;
import java.util.Scanner;

public class calculator {
//    计算器的实现
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
//请输入第一个数字
        System.out.println("请输入第一个数字");
        double num1= scanner.nextDouble();
//     请输入操作符
        System.out.println("  请输入操作符");
String op=scanner.next();
        System.out.println("请输入第二个数字");
//请输入第二个数字
 double num2= scanner.nextDouble();
        switch (op){
            case "+":
                System.out.println("结果是"+add(num1,num2));
                break;
            case "-":
                System.out.println("结果是"+sub(num1,num2));
                break;
            case "*":
                System.out.println("结果是"+mult(num1,num2));
                break;
            case "/":
                System.out.println("结果是"+divide(num1,num2));
                break;
        }
    }

//    .先写加减乘除四个方法
    public static double add(double a,double b)
    {
        return (a+b);
    }
    public static double sub(double a,double b)
    {
        return (a-b);
    }
    public static double mult(double a,double b)
    {
        return (a*b);
    }
    public static double divide(double a,double b)
    {
        return (a/b);
    }

}
